This is an result for the gene singatures as well as assigned cell type for each cluster based on Danaher et al.

knitr::opts_chunk$set(cache=TRUE)


sig_plot <- visualize_clusters(cluster_tsne$cell_type,cluster_tsne[c("TSNE.1","TSNE.2")],title="Danaher cell-type labels",legend_anno= sort(unique(cluster_tsne[,"name_type"])))+scale_color_manual(values = colorRampPalette(c("blue", "red","yellow"))( length(sort(unique(cluster_tsne[,"name_type"])))))+  annotate("text", x = tsne_center[, 1], y = tsne_center[, 2], size = 5,label=c(1:length(tsne_center[,1])))

sig_plot

top_sig <- data.frame(t(sapply(unique(all_type_expr_table$Cluster),function(x){ all_type_expr_table[all_type_expr_table$Cluster == x,][which(all_type_expr_table$precent_count[all_type_expr_table$Cluster == x] == max(all_type_expr_table$precent_count[all_type_expr_table$Cluster == x])),] })))
top_sig$Signature <-lapply(top_sig$Signature,function(y){paste(y)})
top_sig$Cluster <-unique(unlist(top_sig$Cluster))
top_sig <- merge(y=top_sig, x=cluster_type[,c("Cluster","name_type")],by="Cluster")
colnames(top_sig)[2] <- "Assigned_Type"
kable(top_sig)
Cluster Assigned_Type Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
1 CD45 Macrophages 832 5571 5.435 3.699 963 86.397 0.634 611 24.751
2 T_cells T_cells 11147 103645 4.073 3.46 11716 95.143 0.658 7705 85.623
3 T_cells T_cells 16150 139048 3.921 3.382 17068 94.622 0.602 10272.333 93.576
4 CD45 Neutrophils 546 1239 1.998 2.304 1768 30.882 0.06 106.286 5.159
5 Macrophages Macrophages 34 177 5.206 3.208 75 45.333 0.223 16.75 3.172
6 B_cells B_cells 2187 21816 4.088 3.624 2282 95.837 0.507 1157.889 29.179
7 Cytotoxic_cells Cytotoxic_cells 5882 283649 7.919 5.925 5900 99.695 3.563 21021.4 295.397
8 Cytotoxic_cells Cytotoxic_cells 183 1727 7.256 4.298 202 90.594 0.521 105.3 10.058
9 Macrophages Macrophages 10 16 1.6 1.897 25 40 0.11 2.75 0.901
10 Mast_cells Macrophages, Mast_cells 1, 1 1, 9 1, 3 NA, 3.464 1, 1 100, 100 0.25, 1 0.25, 1 0.25, 1
cat("\n")
counter <-1
colnames(score_by_cluster) <- names(cell_list)
apply(score_by_cluster, 1,function(x) { plot_x <- plot(x,ylab="mean expression level per cell",xlab="cell type", main=c("Cluster",counter))
plot_x <- text(x, names(cell_list), cex=0.6, pos=4, col="red")
sum_table <- kable(all_type_expr_table[all_type_expr_table$Cluster == counter,])
plot_x
cat("\n")
print(sum_table)
cat("\n")

counter <<- counter + 1})

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
3 1 B_cells 28 55 1.528 2.360 963 2.908 0.005 5 1.56
4 1 CD45 480 1681 3.502 3.304 963 49.844 0.811 781 42.485
5 1 CD8_T_cells 39 114 2.651 2.869 963 4.050 0.031 29.5 5.545
6 1 Cytotoxic_cells 303 1376 3.193 4.026 963 31.464 0.101 97.5 14.523
7 1 Exhausted_CD8 161 284 1.690 1.945 963 16.719 0.049 47.25 3.961
8 1 Macrophages 832 5571 5.435 3.699 963 86.397 0.634 611 24.751
9 1 Neutrophils 311 654 1.827 2.113 963 32.295 0.061 59.143 3.703
10 1 NK_CD56dim_cells 21 21 1.000 0.000 963 2.181 0.005 5.25 1.146
11 1 NK_cells 6 25 3.571 3.207 963 0.623 0.003 3.333 1.491
12 1 T_cells 143 638 2.913 2.992 963 14.849 0.054 52.167 5.403
13 1 Th1_cells 9 15 1.667 2.000 963 0.935 0.01 10 3.464
14 1 Treg 2 2 1.000 0.000 963 0.208 0.002 2 1.414

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
15 2 B_cells 340 795 2.049 2.444 11716 2.902 0.005 56.222 4.366
16 2 CD45 3646 9692 2.658 2.807 11716 31.120 0.42 4922 91.324
17 2 CD8_T_cells 2649 11130 3.312 3.172 11716 22.610 0.222 2597.5 60.235
18 2 Cytotoxic_cells 7866 112444 5.236 4.344 11716 67.139 0.529 6196.1 104.86
19 2 DC 42 60 1.429 1.564 11716 0.358 0.001 15 2.38
20 2 Exhausted_CD8 1778 3240 1.724 1.991 11716 15.176 0.046 533.75 13.709
21 2 Macrophages 282 408 1.442 1.613 11716 2.407 0.007 77 4.835
22 2 Mast_cells 3 10 3.333 4.041 11716 0.026 0 1.25 0.829
23 2 Neutrophils 19 25 1.316 1.376 11716 0.162 0 2.857 0.67
24 2 NK_CD56dim_cells 173 268 1.540 1.779 11716 1.477 0.004 48.25 3.929
25 2 NK_cells 402 1033 2.275 2.524 11716 3.431 0.016 189.333 10.934
26 2 T_cells 11147 103645 4.073 3.460 11716 95.143 0.658 7705 85.623
27 2 Th1_cells 305 408 1.338 1.393 11716 2.603 0.028 323 19
28 2 Treg 84 163 1.940 2.214 11716 0.717 0.008 98 11.314

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
29 3 B_cells 207 449 1.919 2.297 17068 1.213 0.002 32.444 2.927
30 3 CD45 4863 11961 2.460 2.661 17068 28.492 0.368 6286 99.499
31 3 CD8_T_cells 4141 21377 3.927 3.352 17068 24.262 0.274 4681 85.15
32 3 Cytotoxic_cells 5187 13357 2.174 2.567 17068 30.390 0.046 791.2 15.642
33 3 DC 8 8 1.000 0.000 17068 0.047 0 2.667 0.943
34 3 Exhausted_CD8 1001 1495 1.477 1.644 17068 5.865 0.016 275 9.083
35 3 Macrophages 248 321 1.294 1.309 17068 1.453 0.004 65.25 4.25
36 3 Mast_cells 4 16 4.000 3.464 17068 0.023 0 1.5 0.791
37 3 Neutrophils 31 38 1.188 1.061 17068 0.182 0 4.714 0.869
38 3 NK_CD56dim_cells 137 173 1.263 1.232 17068 0.803 0.002 35.75 3.112
39 3 NK_cells 28 51 1.594 1.881 17068 0.164 0.001 12 2.494
40 3 T_cells 16150 139048 3.921 3.382 17068 94.622 0.602 10272.333 93.576
41 3 Th1_cells 64 82 1.281 1.278 17068 0.375 0.004 67 8.544
42 3 Treg 30 55 1.833 2.167 17068 0.176 0.002 35 6.856

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
43 4 B_cells 58 149 2.328 2.679 1768 3.281 0.005 9.333 1.457
44 4 CD45 265 585 2.208 2.528 1768 14.989 0.189 335 23
45 4 CD8_T_cells 41 94 2.136 2.446 1768 2.319 0.015 27 5
46 4 Cytotoxic_cells 387 1881 3.329 3.853 1768 21.889 0.072 126.6 12.272
47 4 DC 1 1 1.000 NA 1768 0.057 0 0.333 0.333
48 4 Exhausted_CD8 99 151 1.480 1.657 1768 5.600 0.016 27.75 2.926
49 4 Macrophages 391 769 1.835 2.167 1768 22.115 0.07 123.5 6.973
50 4 Neutrophils 546 1239 1.998 2.304 1768 30.882 0.06 106.286 5.159
51 4 NK_CD56dim_cells 7 19 2.714 2.928 1768 0.396 0.001 2.25 0.901
52 4 NK_cells 9 11 1.000 0.000 1768 0.509 0.002 3.667 1.291
53 4 T_cells 259 719 2.153 2.488 1768 14.649 0.039 69.833 5.398
54 4 Th1_cells 8 8 1.000 0.000 1768 0.452 0.005 8 2.828

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
55 5 CD45 2 2 1.000 0.000 75 2.667 0.027 2 1.414
56 5 CD8_T_cells 1 7 7.000 NA 75 1.333 0.013 1 1
57 5 Cytotoxic_cells 21 147 3.769 4.837 75 28.000 0.192 14.4 6.81
58 5 Macrophages 34 177 5.206 3.208 75 45.333 0.223 16.75 3.172
59 5 NK_cells 1 1 1.000 NA 75 1.333 0.004 0.333 0.333
60 5 T_cells 6 35 3.182 3.027 75 8.000 0.033 2.5 1.213
61 5 Th1_cells 1 1 1.000 NA 75 1.333 0.013 1 1

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
62 6 B_cells 2187 21816 4.088 3.624 2282 95.837 0.507 1157.889 29.179
63 6 CD45 539 1249 2.317 2.581 2282 23.620 0.3 684 32.741
64 6 CD8_T_cells 59 149 2.191 2.639 2282 2.585 0.02 44.5 7.194
65 6 Cytotoxic_cells 377 2065 3.542 4.474 2282 16.521 0.063 143.7 18.319
66 6 Exhausted_CD8 59 77 1.305 1.329 2282 2.585 0.007 15.5 2.062
67 6 Macrophages 82 116 1.398 1.592 2282 3.593 0.01 22.75 2.704
68 6 Mast_cells 1 1 1.000 NA 2282 0.044 0 0.25 0.25
69 6 Neutrophils 20 20 1.000 0.000 2282 0.876 0.001 2.857 0.639
70 6 NK_CD56dim_cells 20 20 1.000 0.000 2282 0.876 0.002 5 1.118
71 6 NK_cells 5 5 1.000 0.000 2282 0.219 0.001 1.667 0.745
72 6 T_cells 306 1375 2.847 3.011 2282 13.409 0.051 116.667 8.715
73 6 Th1_cells 16 16 1.000 0.000 2282 0.701 0.007 16 4
74 6 Treg 1 1 1.000 NA 2282 0.044 0 1 1

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
75 7 B_cells 74 270 2.477 3.066 5900 1.254 0.003 20.111 3.7
76 7 CD45 2104 6099 2.899 2.948 5900 35.661 0.503 2969 73.451
77 7 CD8_T_cells 2505 10733 3.266 3.113 5900 42.458 0.421 2483 58.292
78 7 Cytotoxic_cells 5882 283649 7.919 5.925 5900 99.695 3.563 21021.4 295.397
79 7 DC 1 1 1.000 NA 5900 0.017 0 0.333 0.333
80 7 Exhausted_CD8 996 1769 1.663 1.924 5900 16.881 0.051 299.75 10.359
81 7 Macrophages 92 151 1.641 2.020 5900 1.559 0.004 26.5 3.202
82 7 Neutrophils 12 12 1.000 0.000 5900 0.203 0 1.714 0.495
83 7 NK_CD56dim_cells 414 713 1.647 1.908 5900 7.017 0.021 122 6.461
84 7 NK_cells 1052 2835 2.305 2.589 5900 17.831 0.089 523.333 19.206
85 7 T_cells 3853 33071 4.142 3.510 5900 65.305 0.42 2477.167 47.877
86 7 Th1_cells 848 1558 1.837 2.108 5900 14.373 0.166 978 35.609
87 7 Treg 7 7 1.000 0.000 5900 0.119 0.001 7 2.646

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
88 8 B_cells 132 635 3.489 3.304 202 65.347 0.162 32.778 3.561
89 8 CD45 16 29 1.812 2.228 202 7.921 0.094 19 5.196
90 8 CD8_T_cells 6 18 3.000 3.098 202 2.970 0.02 4 1.732
91 8 Cytotoxic_cells 183 1727 7.256 4.298 202 90.594 0.521 105.3 10.058
92 8 Exhausted_CD8 3 3 1.000 0.000 202 1.485 0.004 0.75 0.433
93 8 Macrophages 59 170 2.576 2.701 202 29.208 0.105 21.25 3.072
94 8 Neutrophils 8 8 1.000 0.000 202 3.960 0.006 1.143 0.404
95 8 NK_CD56dim_cells 1 1 1.000 NA 202 0.495 0.001 0.25 0.25
96 8 NK_cells 1 1 1.000 NA 202 0.495 0.002 0.333 0.333
97 8 T_cells 35 176 3.592 3.175 202 17.327 0.063 12.667 2.539
98 8 Th1_cells 2 2 1.000 0.000 202 0.990 0.01 2 1.414

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
99 9 B_cells 1 1 1.0 NA 25 4 0.004 0.111 0.111
100 9 Cytotoxic_cells 4 4 1.0 0.000 25 16 0.016 0.4 0.2
101 9 Macrophages 10 16 1.6 1.897 25 40 0.11 2.75 0.901
102 9 T_cells 2 2 1.0 0.000 25 8 0.013 0.333 0.236

Cluster Signature Barcode_count total_all_gene_Exp avg_non_zero SD cell_total_count precent_count cell_mean_expression cell_mean_expression_sum cell_mean_expression_sd
10 Macrophages 1 1 1 NA 1 100 0.25 0.25 0.25
10 Mast_cells 1 9 3 3.464 1 100 1 1 1

[1] 2 3 4 5 6 7 8 9 10 11

for( i in 1:length(mean_score[1,])){
print(visualize_me(mean_score[,i],cell_list[i],analysis_results$tsne[c("TSNE.1","TSNE.2")],title=names(cell_list)[i]))

#print(plot(mean_score[,i],type = "h",xlab="Single Cell",ylab=colnames(mean_score)[i]))
h <-hist(mean_score[,i],plot = FALSE)

h<- plot(h, freq = TRUE, labels =TRUE, ylim=c(0, 1.2*max(h$counts)),main=c(names(cell_list)[i]," Score per Single Cell"),xlab=paste(sep=" ",names(cell_list)[i],"Expression Level"),ylab="Numbers of cells")
#lay_out(list(h, 1, 1),
#       list(vm, 1, 2))
}